import 'package:flutter/material.dart';
import 'package:sui_shou_pai/module/color.dart';
import 'package:sui_shou_pai/news/data/comment_list_item_data.dart';

import 'comment_list_item.dart';

Widget initCommentList(
    List<CommentListItemData> commentList, BuildContext context) {
  double width = MediaQuery.of(context).size.width;

  List<Widget> commentListWidget = List.generate(commentList.length, (index) {
    return initCommentListItem(commentList[index]);
  });
  return Container(
    margin: EdgeInsets.only(top: 24, bottom: 24),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          width: width,
          margin: EdgeInsets.only(bottom: 6),
          child: Text(
            '评论',
            style: TextStyle(
                fontSize: 18,
                fontWeight: FontWeight.bold,
                fontStyle: FontStyle.italic),
          ),
        ),
        commentListWidget.length == 0
            ? Container(
                alignment: Alignment.center,
                width: width,
                height: 100,
                decoration: BoxDecoration(
                  color: greyF6F6F6,
                  borderRadius: BorderRadius.circular(8),
                ),
                child: Text(
                  "快来抢沙发呀",
                  textAlign: TextAlign.center,
                  style: TextStyle(color: Colors.grey),
                ),
              )
            : Column(children: commentListWidget)
      ],
    ),
  );
}
